package newfeature.jdk8;

import java.util.Arrays;
import java.util.function.Supplier;

/**
 * Created by dl
 */
public class MethodReference {
	public MethodReference(String msg) {
		System.out.println("new me, msg: "+msg);
	}
	public MethodReference() {
		this("no-arg constructor");
	}
	public static MethodReference createMe() {
		return new MethodReference("static-create");
	}

	public static void main(String[] args) {
		Arrays.asList("a","b","c").forEach(System.out::println);

		makeInstance(MethodReference::new);		// refer to non-arg constructor

		makeInstance(MethodReference::createMe);	// refer to a static non-arg method
	}

	public static void makeInstance(Supplier<MethodReference> s) {
		System.out.println(s.get());
	}
}
